package routes

import (
	"os"
	"io/ioutil"
	"go-scripts/config"
	"go-scripts/handler"
)

func init()  {
	Register("GET /views/*", getViews)
}

var gopath string = config.GetEnviroment().Gopath
//访问静态资源
func getViews(app *handler.Global) {
	file, err:= os.Open(gopath + "/src/go-scripts" + app.Request.URL.Path)
	defer file.Close()
	app.CheckErr(err)
	fileBytes, err:= ioutil.ReadAll(file)
	app.CheckErr(err)
	app.SendFile(fileBytes)
}